package com.qf.exception;

import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.ModelAndView;

/**
 * 全局异常拦截器
 * @author lixu
 */
//@ControllerAdvice
@RestControllerAdvice
public class GlobalException {

    @ExceptionHandler(UnauthorizedException.class)
    public String UnauthorizedExceptionHandler(UnauthorizedException e){

        return "流浪地球";
    }

/*    @ExceptionHandler(UnauthorizedException.class)
    public ModelAndView UnauthorizedExceptionHandler(UnauthorizedException e){
        ModelAndView mav = new ModelAndView();
        mav.setViewName("/unauthorizedUrl.html");
        return mav;
    }*/

    @ExceptionHandler(Exception.class)
    public ModelAndView exceptionHandler(Exception e){
        ModelAndView mav = new ModelAndView();
        mav.setViewName("/unauthorizedUrl.html");
        return mav;
    }
}
